/*
 * Part of the ACID Project
 * Developed in 2011 by Morgan Taschuk
 */
package acid.spring.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import javax.sql.DataSource;
import org.postgresql.jdbc3.Jdbc3PoolingDataSource;

/**
 *
 * @author morgan
 */
@Configuration
public class AcidConfiguration {

    @Value("${dataSource.server}")
    private String url;
    @Value("${dataSource.db}")
    private String dbName;
    @Value("${dataSource.user}")
    private String user;
    @Value("${dataSource.password}")
    private String password;

    @Bean
    public DataSource dataSource() {
        Jdbc3PoolingDataSource simpleDriverDataSource = new Jdbc3PoolingDataSource();
        simpleDriverDataSource.setPassword(this.password);
        simpleDriverDataSource.setServerName(this.url);
        simpleDriverDataSource.setDatabaseName(dbName);
        simpleDriverDataSource.setUser(this.user);
        return simpleDriverDataSource;
    }
}
